package chapter1_7_interrupt;

/**
 * @author huayuhao
 * @date 2020/12/16 9:53
 */
public class Interrupt4Test {

    public static void main(String[] args) throws InterruptedException {
        Thread thread = new Thread(() -> {
            // 中断标志为true 时会退出循环，并且清除中断标志
            while(!Thread.currentThread().isInterrupted()){

            }
            System.out.println("thread : " + Thread.currentThread().isInterrupted());
        });

        thread.start();
        Thread.sleep(5000);
        thread.interrupt();

        thread.join();

        System.out.println("main over!");

    }
}
